package mvc.struts.annotation.helper;

import java.util.HashSet;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import mvc.struts.annotation.action.Controller;
import mvc.struts.annotation.util.ClassUtil;


public final class ClassHelper {

	private static final Logger LOGGER =  LoggerFactory.getLogger(ClassUtil.class);
	
	private static final Set<Class<?>>	Class_Set;
	
	static {
		
		String componentScanPackage = ConfigHelper.getComponentScanPath();
		
		LOGGER.info("componentScanPackage path = " + componentScanPackage);
		System.out.println("componentScanPackage path = " + componentScanPackage);
		
		Class_Set = ClassUtil.getClassSet(componentScanPackage);	
		
		for	(Class<?> oneClass : Class_Set)
		{
			LOGGER.info("oneClass Name:" + oneClass.getName());
			
			System.out.println("oneClass Name:" + oneClass.getName());
		}
	}
	
	/**
	 * 
	 * @return
	 */
	public static Set<Class<?>> getClassSet()
	{
		return	Class_Set;
	}
	
	/**
	 * 
	 * @return
	 */
	public static Set<Class<?>> getControllerClassSet()
	{
		Set<Class<?>>	classSet = new HashSet<Class<?>>();
		
		for	(Class<?> cls : Class_Set)
		{
			if	(cls.isAnnotationPresent(Controller.class)) {
				classSet.add(cls);
			}
		}
		
		return	classSet;
	}
	
	/**
	 * 
	 * @return
	 */
	public static Set<Class<?>> getBeanClassSet()
	{
		Set<Class<?>>	classSet = new HashSet<Class<?>>();
		
		classSet.addAll(getControllerClassSet());
		
		return	classSet;
	}
	
}
